﻿using System;
using Csla;
using SystemX.Infrastructure;
using Csla.Core;

namespace SystemX.Csla
{
    /// <summary>
    /// Extension businessListBase class
    /// </summary>
    /// <typeparam name="TId"></typeparam>
    /// <typeparam name="TList">type of BusinessList object</typeparam>
    /// <typeparam name="TItem">type of the Business object in the list</typeparam>
    [Serializable]
    public abstract class XBusinessListBase<TList, TItem> : BusinessListBase<TList, TItem>
        where TList : XBusinessListBase<TList, TItem>
        where TItem : IEditableBusinessObject
    {
        #region .ctor
               /// <summary>
        /// Initializes a new instance of the <see cref="XBusinessListBase{T,C}"/> class.
        /// </summary>
        protected XBusinessListBase()
        {
        }
        #endregion

        #region Properties
        #endregion

        #region Methods
        /// <summary>
        /// Ensures that the specified dependency exists (is not null).
        /// </summary>
        /// <typeparam name="TDependency">
        /// The type of the dependency.
        /// </typeparam>
        /// <param name="dependency">
        /// The dependency instance.
        /// </param>
        /// <returns>
        /// The same <paramref name="dependency"/> instance that was passed to the method.
        /// </returns>
        /// <exception cref="MissingDependencyInjectionException">
        /// When <paramref name="dependency"/> is null.
        /// </exception>
        protected TDependency EnsureDependency<TDependency>(TDependency dependency) where TDependency : class
        {
            if (dependency == null)
                throw new MissingDIException(this.GetType(), typeof(TDependency));
            return dependency;
        }
        #endregion

    }
}
